package com.bbx.mapper_reduce_demo.writable;

import lombok.extern.slf4j.Slf4j;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import sun.rmi.runtime.Log;

import java.io.IOException;

public class PhoneMapper    extends Mapper<LongWritable, Text,Text, PhoneInfoWritable> {
    Text k = new Text();
    PhoneInfoWritable phoneInfoWritable = new PhoneInfoWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        System.out.println(value.toString());
        String[] values = value.toString().split("\t");
        System.out.println(value.toString());
        k.set(values[1]);
        Long upFlow = Long.parseLong(values[3]);
        Long downFlow = Long.parseLong(values[4]);
        phoneInfoWritable.setValue(upFlow,downFlow);
        context.write(k,phoneInfoWritable);

    }
}
